{* $Id$ *}
{include_core file="admin/lib/header.html" title="操作日志展示"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">操作日志管理<span>在这里对操作日志进行管理</span></h2>
    <!-- <a href="{AnUrl('admin_menu/admin/add')}" class="btn btn-success btn-sm right"><i class="icon-add"></i>添加操作日志</a> -->
  </div>
  <div class="search-level1 clearfix" {if $is_advenced == 1}style="display:none;"{/if}>
    <form action="admin_log/admin" method="get">
      <input type="hidden" name="is_advenced" value="0">
      <input type="text" class="left" name="search_filter[realname]" value="{$search_filter.realname}" placeholder="输入操作人真实姓名" >
      <button type="submit" class="btn btn-success btn-sm left">搜索</button>
      <a href="javascript:void(0);" class="close js_advanced {if $is_advenced == 1}js_isOpen open{/if}">高级搜索<em></em></a>
    </form>
  </div>
  <div class="search-form js_advancedForm" {if $is_advenced == 0}style="display:none;"{/if}>
    <form action="admin_log/admin" method="get" class="js_focusSearchForm">
      <input type="hidden" name="is_advenced" value="1">
      <p>
        <label for="" class="search-f-label">用户名：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[realname]" value="{$search_filter.realname}">
      </p>
      <p>
      <label for="" class="search-f-label">操作时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[end_date]" value="{$search_filter.end_date}" id="stopDate">
      </p>
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>
  <!--start:列表-->
  <table class="list-table">
    <caption>按状态：
      <a href='{AnUrl("admin_log/admin?action=")}' {if !$action} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
      <a href='{AnUrl("admin_log/admin?action=create")}' {if $action == 'create'} class="label label-primary" {else} class="label label-default" {/if}>添加/创建</a>
      <a href='{AnUrl("admin_log/admin?action=delete")}' {if $action == 'delete'} class="label label-primary" {else} class="label label-default" {/if}>删除/禁用</a>
      <a href='{AnUrl("admin_log/admin?action=update")}' {if $action == 'update'} class="label label-primary" {else} class="label label-default" {/if}>修改/更新</a>
      <a href='{AnUrl("admin_log/admin?action=change")}' {if $action == 'change'} class="label label-primary" {else} class="label label-default" {/if}>还原</a>
      <a href='{AnUrl("admin_log/admin?action=recover")}' {if $action == 'recover'} class="label label-primary" {else} class="label label-default" {/if}>恢复</a>
      <a href='{AnUrl("admin_log/admin?action=destroy")}' {if $action == 'destroy'} class="label label-primary" {else} class="label label-default" {/if}>彻底删除</a>
    </caption>
    <thead><tr>
      <th>模块名</th>
      <th>操作人</th>
      <th style="min-width:100px">ID</th>
      <th style="min-width:100px">操作类型</th>
      <th style="min-width:200px;">时间</th>
      {if $test == 1}
      <th style="min-width:200px;">备注信息</th>
      {/if}
    </tr></thead>
    <tbody>
      {foreach $admin_log_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          <td>{$v.menu_title}({$v.res_name})</td>
          <td>{$v.admin_user_name}({$v.admin_id})</td>
          <td>{$v.res_id}</td>
          <td>{$v.action_name}({$v.action})</td>
          <td>{$v.add_time}</td>
          {if $test == 1}
          <td>{$v.extra}</td>
          {/if}
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="6">暂无数据</td></tr>
      {/foreach}
    </tbody>
  </table>
  {include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
<script>
var resName = 'admin_menu';
var jsCategoryId = "{$search_filter.category_id}";
$('.js_categoryId').load(siteUrl+'/category/load_category_option?res_name='+resName,function(){
  $('.js_categoryId').find('option').each(function(){
    if ($(this).attr('value') == jsCategoryId) {
      $(this).attr('selected','selected');
    }
  });
});
$(function(){
  // 高级搜索
  $('.js_advanced').click(function(e){
    e.preventDefault();
    var thisObj = $(this);
    var outBox  = thisObj.closest('form');
    if (thisObj.hasClass('js_isOpen')) {
      thisObj.removeClass('js_isOpen open');
      outBox.find('input').show();
      outBox.find('button').show();
      $('.js_advancedForm').hide();
    } else {
      thisObj.addClass('js_isOpen open');
      outBox.find('input').hide();
      outBox.find('button').hide();
      $('.js_advancedForm').show();
    }
  });
  
  // 高级搜索时间验证
  $('.js_searchBtn').click(function(e){
    e.preventDefault();
    var thisObj   = $(this);
    var startDate = $.trim($('#startDate').val());
    var stopDate  = $.trim($('#stopDate').val());
    if (startDate > stopDate) {
      showMsg('结束时间应大于等于开始时间');
      return;
    }
    thisObj.closest('form').submit();
  });

  // 页面复制
  var clip = new ZeroClipboard( $('.js_copyList'), {
    moviePath: "../../../../js/zclip/ZeroClipboard.swf"
  });
  clip.on( 'complete', function(client, args) {
    showMsg("复制成功，复制内容为："+ args.text, 1);
  });
  
  // 查看预览效果
  $('.js_previewBtn').each(function(i){
    $(this).click(function(e){
      e.preventDefault();
      var thisObj = $(this);
      var resName = 'admin_menu';
      var resId = thisObj.closest('tr').attr('data-id');
      
      showPreviewDialog(resName, resId);
    });
  });
});
</script>
{include_core file="admin/lib/footer.html"}